<template>
  <view class="log-item">
    <!-- 左侧：日期与时间 -->
    <view class="left-section">
      <view class="day">{{ day }}</view>
      <view class="month-year">{{ month }} {{ year }}</view>
      <view class="time">{{ time }}</view>
    </view>

    <!-- 分隔线 -->
    <view class="separator"></view>

    <!-- 右侧：详细数据 -->
    <view class="right-section">
      <view class="bmi-progress">
        <text class="bmi">BMI: {{ bmi }}</text>
        <text 
          class="progress" 
          :style="{ color: progressColor }"
        >
          {{ progress > 0 ? '+' : '' }}{{ progress }}
        </text>
      </view>
      <view class="weight-container">
        <text class="weight">{{ weight }} <span class="unit">kg</span></text>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  name: "WeightLog",
  props: {
    day: String,           // 日期的天
    month: String,         // 月份
    year: String,          // 年份
    time: String,          // 时间（例如 "14:30"）
    bmi: [Number, String], // BMI 数值
    progress: Number,      // 进度变化
    weight: [Number, String], // 体重数值
  },
  computed: {
    progressColor() {
      return this.progress > 0 ? "#FF4D4F" : "#52C41A"; // 红色表示上升，绿色表示下降
    },
  },
};
</script>

<style scoped>
/* 整体卡片样式 */
.log-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  margin: 10px 0;
  background: linear-gradient(135deg, #f3f6ff, #e3e9f7); /* 柔和渐变背景 */
  border-radius: 16px;
  box-shadow: 0 8px 12px rgba(0, 0, 0, 0.1); /* 立体阴影 */
  
}



/* 左侧：日期和时间 */
.left-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.day {
  font-size: 28px;
  font-weight: bold;
  color: #333;
  margin-bottom: 4px;
}

.month-year {
  font-size: 12px;
  color: #888;
  margin-bottom: 6px;
}

.time {
  font-size: 14px;
  color: #666;
  background-color: #f0f0f0;
  padding: 4px 8px;
  border-radius: 12px;
  font-weight: 500;
}

/* 分隔线 */
.separator {
  width: 2px;
  height: 70px;
  background-color: #dcdcdc;
  margin: 0 16px;
}

/* 右侧：详细数据 */
.right-section {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  flex: 2;
}

.bmi-progress {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-size: 14px;
  color: #555;
}

.bmi {
  font-weight: 500;
}

.progress {
  font-weight: bold;
}

.weight-container {
  margin-top: 8px;
  background: rgba(255, 122, 89, 0.9); /* 体重背景透明 */
  border-radius: 12px;
  padding: 10px 20px;
  box-shadow: 0 4px 6px rgba(255, 122, 89, 0.2); /* 橙色阴影 */
  position: relative;
  overflow: hidden;
}

.weight {
  font-size: 30px; /* 更大字体 */
  font-weight: bold;
  color: #ffffff; /* 白色字体 */
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2); /* 文字阴影 */
  letter-spacing: 1px;
}

.unit {
  font-size: 16px;
  font-weight: normal;
  margin-left: 4px;
  opacity: 0.9;
}
</style>